﻿<?php require_once(dirname(__FILE__)."/../config/config.php"); ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>礼品管理系统</title>
	</head>
	<body>
	<?php  
if($_SESSION['admin_name']=="")
{

	echo "<script>location.href='admin_login.php';</script>";
}
?>
	<center>
		<?php include("giftmenu.php");?>
<?php  
function upload_image($imgpath)
     {
       $name=$imgpath["name"];
       $tmp_name=$imgpath["tmp_name"];
	$filetype = pathinfo($name, PATHINFO_EXTENSION);//获取后缀
       $size=$imgpath["size"];
	   $filename=date("YmdHis",time()).rand(1000,9999).".".$filetype;
	   $filepath="/userfiles/gift/".$filename;
       $uploadfile = "../userfiles/gift/".$filename;
     
	 
    if(move_uploaded_file($tmp_name,$uploadfile))
         return $filepath; 
  }
 ?>
 <?
 $image=$_FILES['image'];
 $image=upload_image($image);
  $image2=$_FILES['image2'];
 $image2=upload_image($image2);
?>
		<h3>发布礼品信息</h3>
	<form action="gift_action.php?action=add" enctype="multipart/form-data"  method="post">
		<table width="320" border="0" align="center">
			
			<tr>
			<td align="right"> 礼品名字: </td>
			<td><input type="text" name="gift_name" /></td>
			</tr>
			<tr>
			<td align="right"> 礼品兑换积分: </td>
			<td><input type="text" name="integral" /></td>
			</tr>
			<tr>
			<td align="right"> 礼品小图路径: </td>
			<td> <input name="image" type="file" id="image" /></td>
			</tr><tr>
			<td align="right"> 礼品大图路径: </td>
			<td> <input name="image2" type="file" id="image2" /></td>
			</tr>
			<tr>
			<td align="right"> 礼品描述: </td>
			<td><textarea name="description" rows="10" cols="20"></textarea></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
						<input type="submit"   value="填写"/>&nbsp;&nbsp;
						<input type="submit" value="重置"/>				</td>
			</tr>
		</table>
	  </form>
		</center>
		</body>
		</html>